package com.knight.redis.controller;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.knight.redis.dao.RedisTestDao;
import com.knight.redis.entity.Person;

/**
 * 
 * @author fox
 *
 */
@RestController
public class RedisTestController {

	@Autowired
	private RedisTestDao redisTestDao;

	@RequestMapping("/hello")
	public String hello() {
		return "hell0";
	}

	@RequestMapping("/set")
	public String set() {
		Person person = new Person("1", "wfy", 23);
		redisTestDao.stringRedisTemplate();
		redisTestDao.save(person);
		redisTestDao.setList();
		redisTestDao.setMap();
		return "success";
	}

	@RequestMapping("/getStr")
	public String getStr() {
		return redisTestDao.getString();
	}

	@RequestMapping("/getPerson")
	public Person getPerson() {
		return redisTestDao.getPerson();
	}
	
	@RequestMapping("/getList")
	public List<Person> getList() {
		return redisTestDao.getList();
	}
	
	@RequestMapping("/getMap")
	public HashMap<String, List<Person>> getMap() {
		return redisTestDao.getMap();
	}
}
